//
//  LeftViewController.m
//  半糖
//
//  Created by RenShuang on 15/9/17.
//  Copyright (c) 2015年 shuang. All rights reserved.
//

#import "LeftViewController.h"
#import "BaseHeader.h"

@interface LeftViewController ()

@property(nonatomic,retain)NSMutableArray *array1;

@end

@implementation LeftViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.array1 = [NSMutableArray arrayWithObjects:@"夜间模式",@"我的收藏",@"清除缓存",@"关于我们",@"关于潮品",nil];
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-100, -200, SCREEN_WIDTH+200, SCREEN_HEIGHT+400)];
    imageView.userInteractionEnabled = YES;
    imageView.image = [UIImage imageNamed:@"mu.jpg"];
    [self.view addSubview:imageView];
    [imageView release];
    
    
    for (NSInteger i = 0; i < 5; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(SCREEN_WIDTH/3, SCREEN_HEIGHT/5 + (SCREEN_WIDTH/8+SCREEN_WIDTH/15)*i, SCREEN_WIDTH/4, SCREEN_WIDTH/8);
        button.tag = 3000+i;
        if (i == 0) {
            [button setTitle:@"白天模式" forState:UIControlStateSelected];
        }
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        button.backgroundColor = [UIColor whiteColor];
        [button setTitle:[self.array1 objectAtIndex:i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
        
    }
}

- (void)click:(UIButton *)sender
{

    if (sender.tag == 3000) {
        sender.selected = !sender.selected;
        if (sender.selected) {
            [NightHandle shareHandle].temp = NO;
            [NightHandle shareHandle].wordColor = [UIColor whiteColor];
            [NightHandle shareHandle].viewColor = [UIColor grayColor];
            [NightHandle shareHandle].searchBackgroundColor = [UIColor grayColor];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        }else{
            [NightHandle shareHandle].temp = YES;

            [[NSNotificationCenter defaultCenter] postNotificationName:@"day" object:nil];
        [NightHandle shareHandle].wordColor = [UIColor blackColor];
            [NightHandle shareHandle].viewColor = [UIColor whiteColor];
            [NightHandle shareHandle].searchBackgroundColor = [UIColor colorWithRed:245/255. green:245/255. blue:245/255. alpha:1];
        }
    }else if (sender.tag == 3001) {
        
        SCTableViewController *sc = [[SCTableViewController alloc] initWithStyle:UITableViewStylePlain];
        [self presentViewController:sc animated:YES completion:nil];
        
    }else if (sender.tag == 3002){
        [[SDImageCache sharedImageCache] cleanDisk];
        [[DataBase shareDataBase] dropCacheTable];
        [[DataBase shareDataBase] createCacheTable];
        NSUInteger size = [[SDImageCache sharedImageCache] getSize];
        CGFloat mb = size / 1024. / 1024.;
        NSString *string = [NSString stringWithFormat:@"%.2fMB", mb];
        NSString *message = [NSString stringWithFormat:@"已经清理了%@缓存", string];
        UIAlertView *aler = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [aler show];
        [aler release];
    }else if (sender.tag == 3003){
        MineDetailViewController *detail = [[MineDetailViewController alloc] init];
        detail.textStr = @"潮品团队";
        detail.titleStr = @"关于我们";
        [self presentViewController:detail animated:YES completion:^{
            
        }];
    }else{
        MineDetailViewController *detail = [[MineDetailViewController alloc] init];
        detail.titleStr = @"关于潮品";
        detail.textStr = @"潮品当前版本1.0";
        [self presentViewController:detail animated:YES completion:^{
            
        }];

    }
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
